package com.bishe.supermarket.controller;

import com.bishe.supermarket.pojo.vo.Status;
import com.bishe.supermarket.service.SaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Controller
public class SaleController {

    @Autowired
    SaleService saleService;

    @RequestMapping("sale")
    public String sale(){


        return "salePage";
    }

    @RequestMapping("addRec")
    public String addRec(){
//
//        List<String> list = new ArrayList<>();
//        list.add("请选择是否盈利");
//        list.add("是");

        return "addRe";
    }

    //接收表单信息
    @RequestMapping("receiveSale")
    public String receiveSale(String comName, int comNum, int comProfit , HttpSession httpSession){


        Status status = saleService.addSale(comName,comNum,comProfit);
        httpSession.setAttribute("sta",status);
        return "addReMsg";
    }
    //退货处理

    @RequestMapping("backSale")
    public String backSale(){


        return "back";
    }

    //接收退货订单号

    @RequestMapping("receiveBack")
    public String receiveBack(int orderId,HttpSession httpSession){

        Status status = saleService.backSale(orderId);

        httpSession.setAttribute("smsg",status);


        return "backMsg";
    }
}
